import pandas as pd
from .readfiles import FileReader

class ExcelReader(FileReader):

    def __init__(self,originFilePath):
        self.originFilePath = originFilePath

    #判断文件是否为excel文件
    @staticmethod
    def isExcel(originFilePath):
        tails = ['xlsx','xls','xlsm','xlsb','odf','ods','odt']
        fileTail = originFilePath.split('.')[-1]
        return fileTail in tails

    #读取excel文件
    def read(self):
        df = pd.read_excel(self.originFilePath,dtype=str).fillna('').astype(str)
        print(self.originFilePath + ' 读取完毕')
        return df
